<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // sort()方法默认按字符编码ASCII的顺序排列。也会默认将数字转换为字符串，然后根据字符编码进行排序
        var names = ['bob','james','alisa','tutu']
        var num = [11,25,42,65,29,88,76]
        names.sort();
        console.log(names);
        //自定义比较规则：需要为sort（）传入一个参数，这个参数为函数
        function sx(a,b){
            return(a-b);
        }
        num.sort(sx);
        console.log(num);
        
    </script>
</body>
</html>